home *** CD-ROM | disk | FTP | other *** search
/ Computer Select (Limited Edition) / Computer Select.iso / dobbs / v17n04 / handprin.urc / (InkEdit) / CEditPane.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-11  |  2.7 KB  |  125 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.     CEditPane.c
  3.     
  4.     Methods for a text editing pane.
  5.         
  6.     Copyright ⌐ 1989 Symantec Corporation. All rights reserved.
  7.  
  8.  ******************************************************************************/
  9.  
  10.  
  11. #include "CEditPane.h"
  12. #include <Commands.h>
  13. #include <CDocument.h>
  14. #include <CBartender.h>
  15. #include <Constants.h>
  16. #include "Recognizer.h"
  17. extern    CBartender    *gBartender;
  18.  
  19. void CEditPane::IEditPane(CView *anEnclosure, CBureaucrat *aSupervisor)
  20.  
  21. {
  22.     Rect    margin;
  23.     TextFont(monaco);
  24.     TextSize(9);
  25.     CEditText::IEditText(anEnclosure, aSupervisor, 1, 1, 0, 0,
  26.                         sizELASTIC, sizELASTIC, 700);
  27.     FitToEnclosure(TRUE, TRUE);
  28.  
  29.         /**
  30.          **    Give the edit pane a little margin.
  31.          **    Each element of the margin rectangle
  32.          **    specifies by how much to change that
  33.          **    edge. Positive values are down and to
  34.          **    right, negative values are up and to
  35.          **    the left.
  36.          **
  37.          **/
  38.  
  39.     SetRect(&margin, 2, 2, -2, -2);
  40.     ChangeSize(&margin, FALSE);
  41. }
  42.  
  43. void CEditPane::DoCommand(long theCommand)
  44.  
  45. {
  46.     
  47.     if (((theCommand == cmdPaste) || (theCommand == cmdCut)) && 
  48.         !((CDocument *)itsSupervisor)->dirty) {
  49.         
  50.         ((CDocument *)itsSupervisor)->dirty = TRUE;
  51.         gBartender->EnableCmd(cmdSave);
  52.         gBartender->EnableCmd(cmdSaveAs);
  53.     }
  54.  
  55.     inherited::DoCommand(theCommand);
  56. }
  57.  
  58.  
  59. void CEditPane::DoKeyDown(char theChar, Byte keyCode, EventRecord *macEvent)
  60.  
  61. {
  62.     
  63.     inherited::DoKeyDown(theChar, keyCode, macEvent);
  64.  
  65.     switch (keyCode) {
  66.     
  67.         case KeyHome:
  68.         case KeyEnd:
  69.         case KeyPageUp:
  70.         case KeyPageDown:
  71.             break;
  72.             
  73.         default:    
  74.             if (!((CDocument *)itsSupervisor)->dirty) {
  75.                 ((CDocument *)itsSupervisor)->dirty = TRUE;
  76.                 gBartender->EnableCmd(cmdSave);
  77.                 gBartender->EnableCmd(cmdSaveAs);
  78.             }
  79.             break;
  80.     }
  81. }
  82.  
  83.  
  84. void CEditPane::DoAutoKey(char theChar, Byte keyCode, EventRecord *macEvent)
  85.  
  86. {
  87.     
  88.     inherited::DoAutoKey(theChar, keyCode, macEvent);
  89.  
  90.     switch (keyCode) {
  91.     
  92.         case KeyHome:
  93.         case KeyEnd:
  94.         case KeyPageUp:
  95.         case KeyPageDown:
  96.             break;
  97.             
  98.         default:    
  99.             if (!((CDocument *)itsSupervisor)->dirty) {
  100.                 ((CDocument *)itsSupervisor)->dirty = TRUE;
  101.                 gBartender->EnableCmd(cmdSave);
  102.                 gBartender->EnableCmd(cmdSaveAs);
  103.             }
  104.             break;
  105.     }
  106. }
  107.  
  108. void    CEditPane::AdjustCursor(Point where,RgnHandle mouseRgn)
  109.     {
  110.     SetCursor(&arrow);
  111.     }
  112.  
  113.  
  114. void CEditPane::DoClick(Point hitPt,short modifierKeys,long when)
  115.     {
  116.     if (Wacom) {
  117.         hitPt.h = TRecord->xCoord;
  118.         hitPt.v = TRecord->yCoord;
  119.         }
  120.  
  121.     inherited::DoClick(hitPt,modifierKeys,when);
  122.     }
  123.  
  124.  
  125.